import React, { Component } from 'react'
import { connect } from 'dva';
import Link from 'umi/link';
import { Table, Divider } from 'antd';
import Form from './RecordForm';

export interface IProps {
  dispatch?: ({ type }: { type: string, payload?: any }) => Promise<any>;
  children?: React.ReactNode;
  loading?: boolean;
  buttons?: Array<any>;
  history?: any;
  record?: {
    id: string;
    port: string;
    station: string;
    name: string;
    chargingPortNumber: string;
  };
  cond?: any;
  list?: {
    data: Array<any>;
    dataCnt: number;
  };
}


@connect()
class Record extends Component<IProps, any> {

  state = {
    current: 0,
  }

  queryData(params) {
    const { dispatch } = this.props;

  }

  initCurrent = () => {
    this.setState({
      current: 0
    })
  }

  componentDidMount() {
 
  }

  onShowSizeChange = (current, pageSize) => {
    
  }

  render() {
    const { record } = this.props;


    const columns = [
      {
        title: '检查时间',
        dataIndex: 'doneTime',
        key: 'doneTime'
      },
      {
        title: '检查人',
        dataIndex: 'users',
        key: 'users',
        render: (text) => (
          Array.isArray(text) ? text.map(u => u.name).join(', ') : ""
        )
      },
      {
        title: '任务状态',
        dataIndex: 'state',
        key: 'state',
      },
      {
        title: '任务状态',
        dataIndex: 'state',
        key: 'state',
      },
    ];

    const pagination = {
      total: 0,
      showTotal: total => `共 ${total} 条`,
      current: this.state.current,
      showSizeChanger: true,
      pageSizeOptions: ['10', '20', '50', '100'],
      onShowSizeChange: this.onShowSizeChange,
      onChange: (current) => {
        this.setState({ current }, () => this.queryData({ pageNum: current }));
      },
    };

    return (
      <div>
        <Form current={this.state.current} initCurrent={this.initCurrent} />
        <Table
          columns={columns}
          dataSource={[]}
          indentSize={60}
          loading={this.props.loading}
          pagination={pagination}
          bordered
        />
      </div>
    );
  }
}

export default Record;
